﻿using MLSMooc.DAO.Implement.Course;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using MLSMooc.Helper;
using MLSMooc.BO;
using MLSMooc.Service.Implement.Course;

namespace MLSMooc.Controllers
{
    public class CourseController : Controller
    {
        CourseDAO courseDAO = CourseDAO.Getinstance();

        CourseServiceImpl courseService = CourseServiceImpl.Getinstance();

        [HttpGet]
        public async Task<string> GetCourseList()
        {
            var res = await courseDAO.GetCourseList();
            return SerializeHelper.SerializeJson(res);
        }

        [HttpGet]
        public async Task<string> GetCourseVideoList()
        {
            var res = await courseDAO.GetCourseVideoList();
            return SerializeHelper.SerializeJson(res);
        }

        [HttpGet]
        public async Task<string> GetByIdCourseInfo(int id)
        {
            var res = await courseDAO.GetByIdCourseInfo(id);
            return SerializeHelper.SerializeJson(res);
        }

        [HttpGet]
        public async Task<string> GetByProIdCourseList(int ProId)
        {
            var res = await courseDAO.GetByProIdCourseList(ProId);
            return SerializeHelper.SerializeJson(res);
        }

        [HttpPost]
        public async Task<int> InsertCourseBrowseInfo(BrowseBO data)
        {
            var res = await courseService.InsertCourseBrowseInfo(data);
            return res;
        }

        [HttpGet]
        public async Task<string> GetCourse1(int id)
        {
            var res = await courseDAO.GetExam(id);
            return SerializeHelper.SerializeJson(res);
        }
        [HttpGet]
        public async Task<string> GetTanKCourse1(int id)
        {
            var res = await courseDAO.GetMoocTankExam(id);
            return SerializeHelper.SerializeJson(res);
        }

    }
}